package com.qiaofang.collectmanagebff.service.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateUtils {

    /**
     * 正则表达式：验证手机号
     */
    private static String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";

    private static Pattern p = Pattern.compile(REGEX_MOBILE);

    private static  Pattern blankP = Pattern.compile("\\s*|\t|\r|\n");

    /**
     * 校验手机号
     *
     * @param phone
     * @return 校验通过返回true，否则返回false
     */
    public static boolean isMobile(String phone) {
        boolean flag = false;
        if(phone.length() == 11){
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            if(isMatch){
                flag = true;
            }
        }
        return flag;
    }


    public static String replaceBlank(String str) {
        String dest = "";
        if (str!=null) {
            Matcher m = blankP.matcher(str);
            dest = m.replaceAll("");
        }
        return dest;
    }
    public static void main(String[] args) {
        System.out.println(ValidateUtils.replaceBlank("just do it!"));
    }

}
